package flextv.core.logic {

import flash.utils.describeType;

import mx.controls.Alert;
import mx.logging.ILogger;
import mx.logging.Log;
import mx.rpc.events.FaultEvent;
import mx.utils.ObjectUtil;
	

public class Util {
	
	
	private static const LOG: ILogger = Log.getLogger("flextv.core.logic.Util");
	
	
	public function Util() { }
	
	
	
	public static const DEFAULT_FAULT_FUNCTION: Function = function(event: FaultEvent): void {
		LOG.warn(ObjectUtil.toString(event));
		
		Alert.show(event.fault.message, "Fatal Internal Error");
	};
	
	
	
	public static function formatSeconds(inputSeconds: Number): String {
		var min: uint = Math.floor(inputSeconds / 60);
		var sec: uint = Math.floor(inputSeconds % 60);
		// StringUtil.substitute("{0}:{1}", minString, secString);
		return (min < 10 ? "0" : "") + min + ":" +
		       (sec < 10 ? "0" : "") + sec;
	}
	
	public static function getFullQualifiedClassName(clazz: Class): String {
		const type: XML = describeType(clazz);
        const className: String = type.@name;
        return className.replace("::", ".");
	}
	

}
}